var searchRange = function (nums, target) {
  let left = 0;
  let right = nums.length - 1;
  let mid;
  while (left <= right) {
    mid = (left + right) >> 1;
    if (nums[mid] == target) break;
    else if (nums[mid] > target) right = mid - 1;
    else left = mid + 1;
  }
  if (left > right) return [-1, -1];
  let start = mid;
  let end = mid;
  while (nums[start] === nums[start - 1]) start--;
  while (nums[end] === nums[end + 1]) end++;
  return [start, end];
};